/*      */ package com.yc.dao;
/*      */ 
/*      */ import btsm.bean.dbConnector;
/*      */ import com.yc.dao.model.RolesBO;
/*      */ import com.yc.dao.model.SeuMenuBO;
/*      */ import com.yc.dao.model.SysmMenuBO;
/*      */ import com.yc.dao.model.UserBO;
/*      */ import com.yc.util.ListContentsBFO;
import com.yc.util.MyMD5Util;

/*      */ import java.sql.ResultSet;
/*      */ import java.text.SimpleDateFormat;
/*      */ import java.util.ArrayList;
/*      */ import java.util.Date;
/*      */ import java.util.List;
/*      */ import java.util.Map;
/*      */ import org.apache.commons.logging.Log;
/*      */ import org.apache.commons.logging.LogFactory;
/*      */ 
/*      */ public class SystemDAO
/*      */ {
/*   24 */   private static final Log log = LogFactory.getLog(SystemDAO.class);
/*      */ 
/*   26 */   private dbConnector dbcon = null;
/*   27 */   private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
/*      */     private MyMD5Util md5 = new MyMD5Util();
/*      */   private void dbConInit() {
/*   30 */     if (this.dbcon == null)
/*   31 */       this.dbcon = new dbConnector();
/*      */   }
/*      */ 
/*      */   public void dbConClose() {
/*   35 */     if (this.dbcon != null)
/*   36 */       this.dbcon.closeAll();
/*   37 */     this.dbcon = null;
/*      */   }
/*      */ 
/*      */   public String queryMaxMenuID(String strDjJc)
/*      */   {
/*   53 */     dbConInit();
/*   54 */     ResultSet rs = null;
/*   55 */     String strQueryMaxSQLWhere = "";
/*   56 */     String strQueryMaxSQL = "";
/*   57 */     String strMaxNo = "";
/*   58 */     String strMatch = "";
/*   59 */     long lLshCd = 4L;
/*      */     try
/*      */     {
/*   62 */       for (int i = 0; i < lLshCd; i++) {
/*   63 */         strMatch = strMatch + "_";
/*      */       }
/*      */ 
/*   66 */       Date nowTime = new Date();
/*   67 */       SimpleDateFormat fmtDate = null;
/*   68 */       fmtDate = new SimpleDateFormat("yyyyMMdd");
/*   69 */       String strDate = fmtDate.format(nowTime);
/*   70 */       strQueryMaxSQLWhere = strDjJc + strDate;
/*      */ 
/*   72 */       if (strDjJc.equals("Menu"))
/*   73 */         strQueryMaxSQL = "select max(ID) as strMaxNo from sysm_menu where ID like '" + strQueryMaxSQLWhere + strMatch + "' ";
/*   74 */       else if (strDjJc.equals("Role"))
/*   75 */         strQueryMaxSQL = "select max(ID) as strMaxNo from sysm_role where ID like '" + strQueryMaxSQLWhere + strMatch + "' ";
/*   76 */       else if (strDjJc.equals("User")) {
/*   77 */         strQueryMaxSQL = "select max(ID) as strMaxNo from users where ID like '" + strQueryMaxSQLWhere + strMatch + "' ";
/*      */       }
/*   79 */       strQueryMaxSQL = new String(strQueryMaxSQL.getBytes("ISO8859-1"), "UTF-8");
/*   80 */       log.info("strQueryMaxSQL = [" + strQueryMaxSQL + "]");
/*   81 */       rs = this.dbcon.execQuery(strQueryMaxSQL);
/*   82 */       if (rs.next()) {
/*   83 */         strMaxNo = rs.getString("strMaxNo");
/*      */       }
/*   85 */       if (rs != null) {
/*   86 */         rs.close();
/*   87 */         rs = null;
/*      */       }
/*      */ 
/*   91 */       if ((strMaxNo == null) || 
/*   92 */         (strMaxNo.equals("")) || 
/*   93 */         (strMaxNo.length() != strQueryMaxSQLWhere.length() + lLshCd)) {
/*   94 */         for (int i = 1; i < lLshCd; i++) {
/*   95 */           strQueryMaxSQLWhere = strQueryMaxSQLWhere + "0";
/*      */         }
/*   97 */         strMaxNo = strQueryMaxSQLWhere + "1";
/*   98 */         log.debug("是第一个编号=" + strMaxNo);
/*      */       }
/*      */       else
/*      */       {
/*  103 */         long lLshValue = Long.valueOf(
/*  104 */           strMaxNo.substring((int)(strMaxNo.length() - lLshCd), 
/*  105 */           strMaxNo.length())).longValue() + 1L;
/*      */ 
/*  107 */         String strLshBh = String.valueOf(lLshValue);
/*      */ 
/*  109 */         for (int i = strLshBh.length(); i < lLshCd; i++) {
/*  110 */           strLshBh = "0" + strLshBh;
/*      */         }
/*  112 */         strMaxNo = strQueryMaxSQLWhere + strLshBh;
/*  113 */         log.debug("如果不是第一个编号=" + strMaxNo);
/*      */       }
/*      */     } catch (Exception e) {
/*  116 */       e.printStackTrace();
/*      */       try
/*      */       {
/*  119 */         if (rs != null) {
/*  120 */           rs.close();
/*  121 */           rs = null;
/*      */         }
/*      */       } catch (Exception ex) {
/*  124 */         ex.printStackTrace();
/*      */       }
/*      */     }
/*      */     finally
/*      */     {
/*      */       try
/*      */       {
/*  119 */         if (rs != null) {
/*  120 */           rs.close();
/*  121 */           rs = null;
/*      */         }
/*      */       } catch (Exception ex) {
/*  124 */         ex.printStackTrace();
/*      */       }
/*      */     }
/*  127 */     dbConClose();
/*  128 */     return strMaxNo;
/*      */   }
/*      */ 
/*      */   public boolean createMenu(SysmMenuBO bo)
/*      */   {
/*  133 */     boolean flag = true;
/*      */     try
/*      */     {
/*  136 */       dbConInit();
/*  137 */       StringBuffer sqlBuffer = new StringBuffer();
/*  138 */       sqlBuffer.append("insert into sysm_menu(ID, PARENT_ID,NAME,ORDER_,LINK,TIP,LEAF_FLAG,MENU_TYPE) ");
/*  139 */       sqlBuffer.append("  values ( ");
/*  140 */       sqlBuffer.append("'" + bo.getID() + "',");
/*  141 */       sqlBuffer.append("'" + bo.getPARENT_ID() + "',");
/*  142 */       sqlBuffer.append("'" + bo.getNAME() + "',");
/*  143 */       sqlBuffer.append("'" + bo.getORDER_() + "',");
/*  144 */       sqlBuffer.append("'" + bo.getLINK() + "',");
/*  145 */       sqlBuffer.append("'" + bo.getTIP() + "',");
/*  146 */       sqlBuffer.append(" 'true' , ");
/*  147 */       sqlBuffer.append("'" + bo.getMENU_TYPE() + "' )");
/*  148 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*  149 */       this.dbcon.execUpdate(" update sysm_menu set LEAF_FLAG = 'false' where ID = '" + bo.getPARENT_ID() + "'");
/*      */     }
/*      */     catch (Exception e) {
/*  152 */       e.printStackTrace();
/*  153 */       log.error(e.getMessage());
/*  154 */       flag = false;
/*      */     }
/*      */     finally {
/*  157 */       dbConClose();
/*      */     }
/*  159 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean updateMenu(SysmMenuBO bo)
/*      */   {
/*  164 */     boolean flag = true;
/*      */     try
/*      */     {
/*  167 */       dbConInit();
/*  168 */       StringBuffer sqlBuffer = new StringBuffer();
/*  169 */       sqlBuffer.append(" update sysm_menu set PARENT_ID = '" + bo.getPARENT_ID() + "', ");
/*  170 */       sqlBuffer.append(" NAME = '" + bo.getNAME() + "', ORDER_ = '" + bo.getORDER_() + "', MENU_TYPE = '" + bo.getMENU_TYPE() + "', ");
/*  171 */       sqlBuffer.append(" LINK = '" + bo.getLINK() + "', LEAF_FLAG = '" + bo.getLEAF_FLAG() + "', TIP = '" + bo.getTIP() + "'  ");
/*  172 */       sqlBuffer.append(" where id= '" + bo.getID() + "'");
/*  173 */       log.info(sqlBuffer.toString());
/*  174 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */     }
/*      */     catch (Exception e) {
/*  177 */       e.printStackTrace();
/*  178 */       log.error(e.getMessage());
/*  179 */       flag = false;
/*      */     }
/*      */     finally {
/*  182 */       dbConClose();
/*      */     }
/*  184 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean hasChildMenu(String strParentMenuID)
/*      */   {
/*  189 */     boolean flag = false;
/*  190 */     String strSQL = " select PARENT_ID from sysm_menu where PARENT_ID = '" + strParentMenuID + "' ";
/*  191 */     ResultSet rs = null;
/*      */     try
/*      */     {
/*  194 */       dbConInit();
/*  195 */       log.info(strSQL);
/*  196 */       rs = this.dbcon.execQuery(strSQL);
/*  197 */       if (rs.next())
/*  198 */         flag = true;
/*      */     }
/*      */     catch (Exception e) {
/*  201 */       e.printStackTrace();
/*  202 */       log.error(e.getMessage());
/*  203 */       flag = false;
/*      */     }
/*      */     finally {
/*  206 */       dbConClose();
/*      */     }
/*  208 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean updateLeafFlag(String strParentMenuID, boolean deleteFlag)
/*      */   {
/*  213 */     boolean flag = true;
/*      */     try
/*      */     {
/*  216 */       dbConInit();
/*  217 */       StringBuffer sqlBuf = new StringBuffer();
/*  218 */       if (!deleteFlag)
/*      */       {
/*  220 */         sqlBuf.append(" update sysm_menu set LEAF_FLAG = 'true' where id = '" + strParentMenuID + "' ");
/*      */       }
/*  222 */       else sqlBuf.append(" update sysm_menu set LEAF_FLAG = 'false' where id = '" + strParentMenuID + "' ");
/*      */ 
/*  224 */       log.info(sqlBuf.toString());
/*  225 */       this.dbcon.execUpdate(sqlBuf.toString());
/*      */     }
/*      */     catch (Exception e) {
/*  228 */       e.printStackTrace();
/*  229 */       log.error(e.getMessage());
/*  230 */       flag = false;
/*      */     }
/*      */     finally {
/*  233 */       dbConClose();
/*      */     }
/*  235 */     return flag;
/*      */   }
/*      */ 
/*      */   public List getSubMenuTreeByMenuID(String strMenuID)
/*      */   {
/*  244 */     String strSQL = " select * from sysm_menu where PARENT_ID = '" + strMenuID + "' Order By ORDER_ ";
/*  245 */     List list = new ArrayList();
/*  246 */     ResultSet rs = null;
/*      */     try
/*      */     {
/*  249 */       dbConInit();
/*  250 */       log.info(strSQL);
/*  251 */       rs = this.dbcon.execQuery(strSQL);
/*  252 */       while (rs.next()) {
/*  253 */         SysmMenuBO bo = new SysmMenuBO();
/*  254 */         bo.setID(rs.getString("ID"));
/*  255 */         bo.setPARENT_ID(rs.getString("parent_id"));
/*  256 */         bo.setNAME(rs.getString("name"));
/*  257 */         bo.setORDER_(rs.getString("order_"));
/*  258 */         bo.setLINK(rs.getString("link"));
/*  259 */         bo.setLEAF_FLAG(rs.getString("leaf_flag"));
/*  260 */         bo.setTIP(rs.getString("tip"));
/*  261 */         list.add(bo);
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/*  265 */       e.printStackTrace();
/*  266 */       log.error(e.getMessage());
/*  267 */       list = null;
/*      */     }
/*      */     finally {
/*  270 */       dbConClose();
/*      */     }
/*      */ 
/*  273 */     return list;
/*      */   }
/*      */ 
/*      */   public String getRoleNameByUserName(String strUserName)
/*      */   {
/*  278 */     String strSQL = "select distinct NAME from sysm_role where id in      (  select t.ROLE_ID from ( select distinct ROLE_ID from sysm_user_role where  \tUSER_ID in (select u.id from (  select id from users where username = '" + 
/*  280 */       strUserName + "' )as u) )as t )   ";
/*  281 */     ResultSet rs = null;
/*  282 */     String strRole = null;
/*      */     try
/*      */     {
/*  285 */       dbConInit();
/*  286 */       log.info(strSQL);
/*  287 */       rs = this.dbcon.execQuery(strSQL);
/*  288 */       if (rs.next()) {
/*  289 */         String strRoleName = rs.getString("NAME");
/*  290 */         if ((strRoleName == null) || ("".endsWith(strRoleName.trim())))
/*  291 */           strRole = "other";
/*  292 */         if ("系统管理员".equals(strRoleName))
/*  293 */           strRole = "admin";
/*      */         else
/*  295 */           strRole = "other";
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/*  299 */       e.printStackTrace();
/*  300 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/*  303 */       dbConClose();
/*      */     }
/*  305 */     return strRole;
/*      */   }
/*      */ 
/*      */   public List getAllMenuByUserID(String strUserID, String strMenuType)
/*      */   {
/*      */     String strSQL;
/*  317 */     if ((strUserID == null) || ("".equalsIgnoreCase(strUserID.trim())))
/*  318 */       strSQL = " select * from sysm_menu  where MENU_TYPE = '" + strMenuType + "' order by PARENT_ID,ORDER_";
/*      */     else {
/*  320 */       strSQL = " select * from  sysm_menu   where id in  (  select distinct MENU_ID from seu_menu where ROLE_ID in      (  select t.ROLE_ID from ( select distinct ROLE_ID from sysm_user_role where  \t\tUSER_ID in (select u.id from (  select id from users where username = '" + 
/*  323 */         strUserID + "' )as u) )as t )   " + 
/*  324 */         ")  and MENU_TYPE = '" + strMenuType + "'   order by PARENT_ID,ORDER_\t";
/*      */     }
/*      */ 
/*  327 */     List list = new ArrayList();
/*  328 */     ResultSet rs = null;
/*      */     try
/*      */     {
/*  331 */       dbConInit();
/*      */ 
/*  333 */       rs = this.dbcon.execQuery(strSQL);
/*  334 */       while (rs.next()) {
/*  335 */         SysmMenuBO bo = new SysmMenuBO();
/*  336 */         bo.setID(rs.getString("ID"));
/*  337 */         bo.setPARENT_ID(rs.getString("parent_id"));
/*  338 */         bo.setNAME(rs.getString("name"));
/*  339 */         bo.setORDER_(rs.getString("order_"));
/*  340 */         bo.setLINK(rs.getString("link"));
/*  341 */         bo.setLEAF_FLAG(rs.getString("leaf_flag"));
/*  342 */         bo.setTIP(rs.getString("tip"));
/*  343 */         list.add(bo);
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/*  347 */       e.printStackTrace();
/*  348 */       log.error(e.getMessage());
/*  349 */       list = null;
/*      */     }
/*      */     finally {
/*  352 */       dbConClose();
/*      */     }
/*      */ 
/*  355 */     return list;
/*      */   }
/*      */ 
/*      */   public List getParentMenuTree(String strMenuID, String strEditMenuId)
/*      */   {
/*  364 */     String strSQL = " select * from sysm_menu where PARENT_ID = '" + strMenuID + "'  and id != '" + strEditMenuId + "' Order By ORDER_ ";
/*  365 */     List list = new ArrayList();
/*  366 */     ResultSet rs = null;
/*      */     try
/*      */     {
/*  369 */       dbConInit();
/*  370 */       log.info(strSQL);
/*  371 */       rs = this.dbcon.execQuery(strSQL);
/*  372 */       while (rs.next()) {
/*  373 */         SysmMenuBO bo = new SysmMenuBO();
/*  374 */         bo.setID(rs.getString("ID"));
/*  375 */         bo.setPARENT_ID(rs.getString("parent_id"));
/*  376 */         bo.setNAME(rs.getString("name"));
/*  377 */         bo.setORDER_(rs.getString("order_"));
/*  378 */         bo.setLINK(rs.getString("link"));
/*  379 */         bo.setLEAF_FLAG(rs.getString("leaf_flag"));
/*  380 */         bo.setTIP(rs.getString("tip"));
/*  381 */         list.add(bo);
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/*  385 */       e.printStackTrace();
/*  386 */       log.error(e.getMessage());
/*  387 */       list = null;
/*      */     }
/*      */     finally {
/*  390 */       dbConClose();
/*      */     }
/*      */ 
/*  393 */     return list;
/*      */   }
/*      */ 
/*      */   public SysmMenuBO getMenuInfoByID(String strMenuID)
/*      */   {
/*  401 */     String strSQL = " select * from sysm_menu where id = '" + strMenuID + "'";
/*  402 */     ResultSet rs = null;
/*  403 */     SysmMenuBO bo = null;
/*      */     try
/*      */     {
/*  406 */       dbConInit();
/*  407 */       log.info(strSQL);
/*  408 */       rs = this.dbcon.execQuery(strSQL);
/*  409 */       if (rs.next()) {
/*  410 */         bo = new SysmMenuBO();
/*  411 */         bo.setID(rs.getString("ID"));
/*  412 */         bo.setPARENT_ID(rs.getString("parent_id"));
/*  413 */         bo.setNAME(rs.getString("name"));
/*  414 */         bo.setORDER_(rs.getString("order_"));
/*  415 */         bo.setLINK(rs.getString("link"));
/*  416 */         bo.setLEAF_FLAG(rs.getString("leaf_flag"));
/*  417 */         bo.setTIP(rs.getString("tip"));
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/*  421 */       e.printStackTrace();
/*  422 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/*  425 */       dbConClose();
/*      */     }
/*      */ 
/*  428 */     return bo;
/*      */   }
/*      */ 
/*      */   public boolean deleteMenyByID(String strMenuId)
/*      */   {
/*  434 */     boolean flag = true;
/*      */     try
/*      */     {
/*  437 */       dbConInit();
/*  438 */       StringBuffer sqlBuffer = new StringBuffer();
/*  439 */       sqlBuffer.append("delete from sysm_menu where ID = '" + strMenuId + "' ");
/*  440 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */     }
/*      */     catch (Exception e) {
/*  443 */       e.printStackTrace();
/*  444 */       log.error(e.getMessage());
/*  445 */       flag = false;
/*      */     }
/*      */     finally {
/*  448 */       dbConClose();
/*      */     }
/*  450 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean createRoles(RolesBO bo)
/*      */   {
/*  456 */     boolean flag = true;
/*      */     try
/*      */     {
/*  459 */       dbConInit();
/*  460 */       StringBuffer sqlBuffer = new StringBuffer();
/*  461 */       sqlBuffer.append("insert into sysm_role(ID, NAME) ");
/*  462 */       sqlBuffer.append("  values ( ");
/*  463 */       sqlBuffer.append("'" + bo.getId() + "',");
/*  464 */       sqlBuffer.append("'" + bo.getNAME() + "') ");
/*  465 */       log.info(sqlBuffer.toString());
/*  466 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */     }
/*      */     catch (Exception e) {
/*  469 */       e.printStackTrace();
/*  470 */       log.error(e.getMessage());
/*  471 */       flag = false;
/*      */     }
/*      */     finally {
/*  474 */       dbConClose();
/*      */     }
/*  476 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean updateRoles(RolesBO bo)
/*      */   {
/*  481 */     boolean flag = true;
/*      */     try
/*      */     {
/*  484 */       dbConInit();
/*  485 */       StringBuffer sqlBuffer = new StringBuffer();
/*  486 */       sqlBuffer.append(" update sysm_role set NAME = '" + bo.getNAME() + "' ");
/*  487 */       sqlBuffer.append(" where id= '" + bo.getId() + "'");
/*  488 */       log.info(sqlBuffer.toString());
/*  489 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */     }
/*      */     catch (Exception e) {
/*  492 */       e.printStackTrace();
/*  493 */       log.error(e.getMessage());
/*  494 */       flag = false;
/*      */     }
/*      */     finally {
/*  497 */       dbConClose();
/*      */     }
/*  499 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean deleteRoles(String strRoleID)
/*      */   {
/*  504 */     boolean flag = true;
/*      */     try
/*      */     {
/*  507 */       dbConInit();
/*  508 */       String strSQL = "delete from sysm_role where ID = '" + strRoleID + "' ";
/*  509 */       log.info(strSQL);
/*  510 */       this.dbcon.execUpdate(strSQL);
/*  511 */       strSQL = "delete from sysm_user_role where ROLE_ID = '" + strRoleID + "' ";
/*  512 */       log.info(strSQL);
/*  513 */       this.dbcon.execUpdate(strSQL);
/*  514 */       strSQL = "delete from seu_menu where ROLE_ID = '" + strRoleID + "' ";
/*  515 */       log.info(strSQL);
/*  516 */       this.dbcon.execUpdate(strSQL);
/*  517 */       strSQL = " update users set rights = '' where rights = '" + strRoleID + "' ";
/*  518 */       log.info(strSQL);
/*  519 */       this.dbcon.execUpdate(strSQL);
/*      */     }
/*      */     catch (Exception e) {
/*  522 */       e.printStackTrace();
/*  523 */       log.error(e.getMessage());
/*  524 */       flag = false;
/*      */     }
/*      */     finally {
/*  527 */       dbConClose();
/*      */     }
/*  529 */     return flag;
/*      */   }
/*      */ 
/*      */   public RolesBO getRolesInforByID(String strID)
/*      */   {
/*  534 */     String strSQL = " select * from sysm_role where id = '" + strID + "'";
/*  535 */     ResultSet rs = null;
/*  536 */     RolesBO bo = null;
/*      */     try
/*      */     {
/*  539 */       dbConInit();
/*  540 */       log.info(strSQL);
/*  541 */       rs = this.dbcon.execQuery(strSQL);
/*  542 */       if (rs.next()) {
/*  543 */         bo = new RolesBO();
/*  544 */         bo.setId(rs.getString("ID"));
/*  545 */         bo.setNAME(rs.getString("name"));
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/*  549 */       e.printStackTrace();
/*  550 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/*  553 */       dbConClose();
/*      */     }
/*  555 */     return bo;
/*      */   }
/*      */ 
/*      */   public ListContentsBFO getRolesList(Map condition)
/*      */   {
/*  561 */     ListContentsBFO bfo = new ListContentsBFO();
/*  562 */     int start = Integer.parseInt(condition.get("start").toString());
/*  563 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*      */ 
/*  566 */     ResultSet rs = null;
/*  567 */     RolesBO bo = null;
/*  568 */     List list = new ArrayList();
/*      */     try
/*      */     {
/*  571 */       dbConInit();
/*  572 */       String strSQL = " select count(id) from sysm_role ";
/*  573 */       log.info(strSQL);
/*  574 */       rs = this.dbcon.execQuery(strSQL);
/*  575 */       if (rs.next()) {
/*  576 */         bfo.setTotalSize(rs.getInt(1));
/*      */       }
/*  578 */       strSQL = " select * from sysm_role limit " + start + ", " + limit;
/*  579 */       log.info(strSQL);
/*  580 */       rs = this.dbcon.execQuery(strSQL);
/*  581 */       while (rs.next()) {
/*  582 */         bo = new RolesBO();
/*  583 */         bo.setId(rs.getString("ID"));
/*  584 */         bo.setNAME(rs.getString("name"));
/*  585 */         list.add(bo);
/*      */       }
/*  587 */       bfo.setData(list.toArray());
/*      */     }
/*      */     catch (Exception e) {
/*  590 */       e.printStackTrace();
/*  591 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/*  594 */       dbConClose();
/*      */     }
/*  596 */     return bfo;
/*      */   }
/*      */ 
/*      */   public List getRolesList()
/*      */   {
/*  601 */     ResultSet rs = null;
/*  602 */     RolesBO bo = null;
/*  603 */     List list = new ArrayList();
/*      */     try
/*      */     {
/*  606 */       dbConInit();
/*  607 */       String strSQL = " select * from sysm_role  ";
/*  608 */       log.info(strSQL);
/*  609 */       rs = this.dbcon.execQuery(strSQL);
/*  610 */       while (rs.next()) {
/*  611 */         bo = new RolesBO();
/*  612 */         bo.setId(rs.getString("ID"));
/*  613 */         bo.setNAME(rs.getString("name"));
/*  614 */         list.add(bo);
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/*  618 */       e.printStackTrace();
/*  619 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/*  622 */       dbConClose();
/*      */     }
/*  624 */     return list;
/*      */   }
/*      */ 
/*      */   public ListContentsBFO getUserListByRoleID(Map condition)
/*      */   {
/*  629 */     ListContentsBFO bfo = new ListContentsBFO();
/*  630 */     int start = Integer.parseInt(condition.get("start").toString());
/*  631 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  632 */     String strRoleID = condition.get("ROLE_ID").toString();
/*      */ 
/*  634 */     ResultSet rs = null;
/*  635 */     UserBO bo = null;
/*  636 */     List list = new ArrayList();
/*      */     try
/*      */     {
/*  639 */       dbConInit();
/*  640 */       String strSQL = " select count(id) from users where rights ='" + strRoleID + "' ";
/*  641 */       log.info(strSQL);
/*  642 */       rs = this.dbcon.execQuery(strSQL);
/*  643 */       if (rs.next()) {
/*  644 */         bfo.setTotalSize(rs.getInt(1));
/*      */       }
/*  646 */       strSQL = " select id,username from users where rights ='" + strRoleID + "' limit " + start + ", " + limit;
/*  647 */       log.info(strSQL);
/*  648 */       rs = this.dbcon.execQuery(strSQL);
/*  649 */       while (rs.next()) {
/*  650 */         bo = new UserBO();
/*  651 */         bo.setId(rs.getString("id"));
/*  652 */         bo.setUsername(rs.getString("username"));
/*  653 */         list.add(bo);
/*      */       }
/*  655 */       bfo.setData(list.toArray());
/*      */     }
/*      */     catch (Exception e) {
/*  658 */       e.printStackTrace();
/*  659 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/*  662 */       dbConClose();
/*      */     }
/*  664 */     return bfo;
/*      */   }
/*      */ 
/*      */   public List getMenuIdByRoleID(String strRoleID)
/*      */   {
/*  671 */     ResultSet rs = null;
/*  672 */     List list = new ArrayList();
/*      */     try
/*      */     {
/*  675 */       dbConInit();
/*  676 */       String strSQL = " select MENU_ID from seu_menu where ROLE_ID = '" + strRoleID + "' ";
/*  677 */       log.info(strSQL);
/*  678 */       rs = this.dbcon.execQuery(strSQL);
/*  679 */       while (rs.next())
/*  680 */         list.add(rs.getString("MENU_ID"));
/*      */     }
/*      */     catch (Exception e)
/*      */     {
/*  684 */       e.printStackTrace();
/*  685 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/*  688 */       dbConClose();
/*      */     }
/*  690 */     return list;
/*      */   }
/*      */ 
/*      */   public boolean deleteFuncByRoleId(String strRoleID)
/*      */   {
/*  695 */     boolean flag = true;
/*      */     try
/*      */     {
/*  698 */       dbConInit();
/*  699 */       StringBuffer sqlBuffer = new StringBuffer();
/*  700 */       sqlBuffer.append("delete from seu_menu where ROLE_ID = '" + strRoleID + "' ");
/*  701 */       log.info(sqlBuffer.toString());
/*  702 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */     }
/*      */     catch (Exception e) {
/*  705 */       e.printStackTrace();
/*  706 */       log.error(e.getMessage());
/*  707 */       flag = false;
/*      */     }
/*      */     finally {
/*  710 */       dbConClose();
/*      */     }
/*  712 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean saveFunc(List list)
/*      */   {
/*  717 */     boolean flag = true;
/*      */     try
/*      */     {
/*  720 */       dbConInit();
/*  721 */       StringBuffer sqlBuffer = new StringBuffer();
/*  722 */       if ((list != null) && (list.size() > 0))
/*      */       {
/*  724 */         for (int i = 0; i < list.size(); i++)
/*      */         {
/*  726 */           if (sqlBuffer.length() > 1)
/*  727 */             sqlBuffer.delete(0, sqlBuffer.length() - 1);
/*  728 */           SeuMenuBO bo = (SeuMenuBO)list.get(i);
/*  729 */           sqlBuffer.append("insert into seu_menu( ROLE_ID, MENU_ID ) ");
/*  730 */           sqlBuffer.append("  values ( ");
/*  731 */           sqlBuffer.append("'" + bo.getROLE_ID() + "',");
/*  732 */           sqlBuffer.append("'" + bo.getMENU_ID() + "') ");
/*  733 */           log.info(sqlBuffer.toString());
/*  734 */           this.dbcon.execUpdate(sqlBuffer.toString());
/*      */         }
/*      */       }
/*      */     }
/*      */     catch (Exception e)
/*      */     {
/*  740 */       e.printStackTrace();
/*  741 */       log.error(e.getMessage());
/*  742 */       flag = false;
/*      */     }
/*      */     finally {
/*  745 */       dbConClose();
/*      */     }
/*  747 */     return flag;
/*      */   }
/*      */ 
/*      */   public ListContentsBFO getUserList(Map condition)
/*      */   {
/*  753 */     ListContentsBFO bfo = new ListContentsBFO();
/*  754 */     int start = Integer.parseInt(condition.get("start").toString());
/*  755 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*  756 */     ResultSet rs = null;
/*  757 */     List list = new ArrayList();
/*      */     try
/*      */     {
/*  760 */       dbConInit();
/*  761 */       String strSQL = " select count(id) from users ";
/*  762 */       log.info(strSQL);
/*  763 */       rs = this.dbcon.execQuery(strSQL);
/*  764 */       if (rs.next()) {
/*  765 */         bfo.setTotalSize(rs.getInt(1));
/*      */       }
/*  767 */       strSQL = " select * from users limit " + start + ", " + limit;
/*  768 */       log.info(strSQL);
/*  769 */       rs = this.dbcon.execQuery(strSQL);
/*  770 */       while (rs.next()) {
/*  771 */         UserBO bo = new UserBO();
/*  772 */         bo.setId(rs.getString("ID"));
/*  773 */         bo.setUsername(rs.getString("username"));
/*  774 */         bo.setSkin(rs.getString("skin"));
/*  775 */         bo.setTruename(rs.getString("truename"));
/*  776 */         bo.setIdentity(rs.getString("identity"));
/*  777 */         bo.setTelephone(rs.getString("telephone"));
/*  778 */         bo.setAddress(rs.getString("address"));
/*  779 */         bo.setLogindisabled(rs.getString("logindisabled"));
/*  780 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*  781 */         list.add(bo);
/*      */       }
/*  783 */       bfo.setData(list.toArray());
/*      */     }
/*      */     catch (Exception e) {
/*  786 */       e.printStackTrace();
/*  787 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/*  790 */       dbConClose();
/*      */     }
/*  792 */     return bfo;
/*      */   }
/*      */ 
/*      */   public List getUserListForRoles()
/*      */   {
/*  797 */     ResultSet rs = null;
/*  798 */     List list = new ArrayList();
/*      */     try
/*      */     {
/*  801 */       dbConInit();
/*  802 */       String strSQL = " select * from users where rights='' ";
/*  803 */       log.info(strSQL);
/*  804 */       rs = this.dbcon.execQuery(strSQL);
/*  805 */       while (rs.next()) {
/*  806 */         UserBO bo = new UserBO();
/*  807 */         bo.setId(rs.getString("ID"));
/*  808 */         bo.setUsername(rs.getString("username"));
/*  809 */         list.add(bo);
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/*  813 */       e.printStackTrace();
/*  814 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/*  817 */       dbConClose();
/*      */     }
/*  819 */     return list;
/*      */   }
/*      */ 
/*      */   public boolean createUser(UserBO bo)
/*      */   {
/*  826 */     boolean flag = true;
/*      */     try
/*      */     {
/*  829 */       dbConInit();
/*  830 */       StringBuffer sqlBuffer = new StringBuffer();
/*  831 */       sqlBuffer.append("insert into users(id, username,passwd,rights,skin,truename,identity,telephone,address,logindisabled,refreshtime ) ");
/*  832 */       sqlBuffer.append("  values ( ");
/*  833 */       sqlBuffer.append("'" + bo.getId() + "',");
/*  834 */       sqlBuffer.append("'" + bo.getUsername() + "',");
/*  835 */       sqlBuffer.append("'" + md5.getMD5ofStr(bo.getPasswd()) + "',");
/*  836 */       sqlBuffer.append("'" + bo.getRights() + "',");
/*  837 */       sqlBuffer.append("'" + bo.getSkin() + "',");
/*  838 */       sqlBuffer.append("'" + bo.getTruename() + "',");
/*  839 */       sqlBuffer.append("'" + bo.getIdentity() + "',");
/*  840 */       sqlBuffer.append("'" + bo.getTelephone() + "',");
/*  841 */       sqlBuffer.append("'" + bo.getAddress() + "',");
/*  842 */       sqlBuffer.append("'" + bo.getLogindisabled() + "',");
/*  843 */       sqlBuffer.append("'" + this.sdf.format(new Date()) + "' ) ");
/*  844 */       log.info(sqlBuffer.toString());
/*  845 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */ 
/*  847 */       String strUserAndRoleSQL = "insert into sysm_user_role(USER_ID, ROLE_ID)   values ( '" + bo.getId() + "','" + bo.getRights() + "' )";
/*  848 */       log.info(strUserAndRoleSQL.toString());
/*  849 */       this.dbcon.execUpdate(strUserAndRoleSQL.toString());
/*      */     }
/*      */     catch (Exception e)
/*      */     {
/*  853 */       e.printStackTrace();
/*  854 */       log.error(e.getMessage());
/*  855 */       flag = false;
/*      */     }
/*      */     finally {
/*  858 */       dbConClose();
/*      */     }
/*  860 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean updateUser(UserBO bo)
/*      */   {
/*  865 */     boolean flag = true;
/*      */     try
/*      */     {
/*  868 */       dbConInit();
/*  869 */       StringBuffer sqlBuffer = new StringBuffer();
/*  870 */       sqlBuffer.append(" update users set username = '" + bo.getUsername() + "', ");
/*  871 */       if ((bo.getPasswd() != null) && (!"".equalsIgnoreCase(bo.getPasswd().trim())))
/*  872 */         sqlBuffer.append(" passwd = '" + md5.getMD5ofStr(bo.getPasswd()) + "', ");
/*  873 */       sqlBuffer.append(" rights = '" + bo.getRights() + "', ");
/*  874 */       sqlBuffer.append(" skin = '" + bo.getSkin() + "', ");
/*  875 */       sqlBuffer.append(" truename = '" + bo.getTruename() + "', ");
/*  876 */       sqlBuffer.append(" identity = '" + bo.getIdentity() + "', ");
/*  877 */       sqlBuffer.append(" telephone = '" + bo.getTelephone() + "', ");
/*  878 */       sqlBuffer.append(" address = '" + bo.getAddress() + "', ");
/*  879 */       sqlBuffer.append(" refreshtime = '" + this.sdf.format(new Date()) + "', ");
/*  880 */       sqlBuffer.append(" logindisabled = '" + bo.getLogindisabled() + "' ");
/*  881 */       sqlBuffer.append(" where id= '" + bo.getId() + "'");
/*  882 */       log.info(sqlBuffer.toString());
/*  883 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */ 
/*  885 */       String strUserAndRoleSQL = "update sysm_user_role set ROLE_ID = '" + bo.getRights() + "' where USER_ID= '" + bo.getId() + "' ";
/*  886 */       log.info(strUserAndRoleSQL.toString());
/*  887 */       this.dbcon.execUpdate(strUserAndRoleSQL.toString());
/*      */     }
/*      */     catch (Exception e)
/*      */     {
/*  891 */       e.printStackTrace();
/*  892 */       log.error(e.getMessage());
/*  893 */       flag = false;
/*      */     }
/*      */     finally {
/*  896 */       dbConClose();
/*      */     }
/*  898 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean updateUserBySelf(UserBO bo)
/*      */   {
/*  903 */     boolean flag = true;
/*      */     try
/*      */     {
/*  906 */       log.info("用户【" + bo.getUsername() + "】修改自己信息---开始");
/*  907 */       dbConInit();
/*  908 */       StringBuffer sqlBuffer = new StringBuffer();
/*  909 */       sqlBuffer.append(" update users set  ");
/*  910 */       sqlBuffer.append(" gender = '" + bo.getGender() + "', ");
/*  911 */       sqlBuffer.append(" birthday = '" + this.sdf.format(bo.getBirthday()) + "', ");
/*  912 */       sqlBuffer.append(" email = '" + bo.getEmail() + "', ");
/*  913 */       sqlBuffer.append(" identity = '" + bo.getIdentity() + "', ");
/*  914 */       sqlBuffer.append(" telephone = '" + bo.getTelephone() + "', ");
/*  915 */       sqlBuffer.append(" address = '" + bo.getAddress() + "', ");
/*  916 */       sqlBuffer.append(" telephoneForCom = '" + bo.getTelephoneForCom() + "', ");
/*  917 */       sqlBuffer.append(" addresForCom = '" + bo.getAddresForCom() + "', ");
/*  918 */       sqlBuffer.append(" mobile = '" + bo.getMobile() + "', ");
/*  919 */       sqlBuffer.append(" truename = '" + bo.getTruename() + "', ");
/*  920 */       sqlBuffer.append(" refreshtime = '" + this.sdf.format(new Date()) + "' ");
/*  921 */       sqlBuffer.append(" where username = '" + bo.getUsername() + "'");
/*  922 */       log.info(sqlBuffer.toString());
/*  923 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */     }
/*      */     catch (Exception e)
/*      */     {
/*  927 */       log.info("用户【" + bo.getUsername() + "】修改自己信息---失败");
/*  928 */       e.printStackTrace();
/*  929 */       log.error(e.getMessage());
/*  930 */       flag = false;
/*      */     }
/*      */     finally {
/*  933 */       log.info("用户【" + bo.getUsername() + "】修改自己信息---结束");
/*  934 */       dbConClose();
/*      */     }
/*  936 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean updatePassword(String strUserID, String strPasswd)
/*      */   {
/*  943 */     boolean flag = true;
/*      */     try
/*      */     {
/*  946 */       dbConInit();
/*  947 */       StringBuffer sqlBuffer = new StringBuffer();
/*  948 */       sqlBuffer.append(" update users set  ");
/*  949 */       sqlBuffer.append(" passwd = password(\"" + strPasswd + "\") ");
/*  950 */       sqlBuffer.append(" where username= '" + strUserID + "'");
/*  951 */       log.info(sqlBuffer.toString());
/*  952 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */     }
/*      */     catch (Exception e) {
/*  955 */       e.printStackTrace();
/*  956 */       log.error(e.getMessage());
/*  957 */       flag = false;
/*      */     }
/*      */     finally {
/*  960 */       dbConClose();
/*      */     }
/*  962 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean isAvialable(String strUserName, String strOldPassword, boolean isID)
/*      */   {
/*  967 */     boolean flag = false;
/*      */     try
/*      */     {
/*  970 */       dbConInit();
/*  971 */       StringBuffer sqlBuffer = new StringBuffer();
/*  972 */       sqlBuffer.append(" select id from users where ");
/*  973 */       sqlBuffer.append(" passwd = password(\"" + strOldPassword + "\") ");
/*  974 */       if (isID)
/*  975 */         sqlBuffer.append(" and id = '" + strUserName + "'");
/*      */       else
/*  977 */         sqlBuffer.append(" and username = '" + strUserName + "'");
/*  978 */       log.info(sqlBuffer.toString());
/*  979 */       ResultSet rs = null;
/*  980 */       rs = this.dbcon.execQuery(sqlBuffer.toString());
/*  981 */       if (rs.next())
/*  982 */         flag = true;
/*      */     }
/*      */     catch (Exception e) {
/*  985 */       e.printStackTrace();
/*  986 */       log.error(e.getMessage());
/*  987 */       flag = false;
/*      */     }
/*      */     finally {
/*  990 */       dbConClose();
/*      */     }
/*  992 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean deleteUser(String strID)
/*      */   {
/*  998 */     boolean flag = true;
/*      */     try
/*      */     {
/* 1001 */       dbConInit();
/* 1002 */       StringBuffer sqlBuffer = new StringBuffer();
/* 1003 */       sqlBuffer.append("delete from users where id = '" + strID + "' ");
/* 1004 */       log.info(sqlBuffer.toString());
/* 1005 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */ 
/* 1007 */       String strUserAndRoleSQL = "delete sysm_user_role where USER_ID= '" + strID + "' ";
/* 1008 */       log.info(strUserAndRoleSQL.toString());
/* 1009 */       this.dbcon.execUpdate(strUserAndRoleSQL.toString());
/*      */     }
/*      */     catch (Exception e) {
/* 1012 */       e.printStackTrace();
/* 1013 */       log.error(e.getMessage());
/* 1014 */       flag = false;
/*      */     }
/*      */     finally {
/* 1017 */       dbConClose();
/*      */     }
/* 1019 */     return flag;
/*      */   }
/*      */ 
/*      */   public UserBO getUserById(String strID)
/*      */   {
/* 1024 */     UserBO bo = null;
/* 1025 */     ResultSet rs = null;
/*      */     try
/*      */     {
/* 1028 */       dbConInit();
/* 1029 */       String strSQL = " select * from users  where id = '" + strID + "' ";
/* 1030 */       log.info(strSQL);
/* 1031 */       rs = this.dbcon.execQuery(strSQL);
/* 1032 */       if (rs.next()) {
/* 1033 */         bo = new UserBO();
/* 1034 */         bo.setId(rs.getString("ID"));
/* 1035 */         bo.setUsername(rs.getString("username"));
/* 1036 */         bo.setSkin(rs.getString("skin"));
/* 1037 */         bo.setTruename(rs.getString("truename"));
/* 1038 */         bo.setIdentity(rs.getString("identity"));
/* 1039 */         bo.setTelephone(rs.getString("telephone"));
/* 1040 */         bo.setAddress(rs.getString("address"));
/* 1041 */         bo.setLogindisabled(rs.getString("logindisabled"));
/* 1042 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/* 1046 */       e.printStackTrace();
/* 1047 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/* 1050 */       dbConClose();
/*      */     }
/* 1052 */     return bo;
/*      */   }
/*      */ 
/*      */   public UserBO getUserByName(String strName)
/*      */   {
/* 1057 */     UserBO bo = null;
/* 1058 */     ResultSet rs = null;
/*      */     try
/*      */     {
/* 1061 */       dbConInit();
/* 1062 */       String strSQL = " select * from users  where username = '" + strName + "' ";
/* 1063 */       log.info(strSQL);
/* 1064 */       rs = this.dbcon.execQuery(strSQL);
/* 1065 */       if (rs.next()) {
/* 1066 */         bo = new UserBO();
/* 1067 */         bo.setId(rs.getString("ID"));
/* 1068 */         bo.setUsername(rs.getString("username"));
/* 1069 */         bo.setSkin(rs.getString("skin"));
/* 1070 */         bo.setTruename(rs.getString("truename"));
/* 1071 */         bo.setIdentity(rs.getString("identity"));
/* 1072 */         bo.setTelephone(rs.getString("telephone"));
/* 1073 */         bo.setAddress(rs.getString("address"));
/* 1074 */         bo.setLogindisabled(rs.getString("logindisabled"));
/* 1075 */         bo.setGender(rs.getString("gender"));
/* 1076 */         bo.setBirthday(rs.getDate("birthday"));
/* 1077 */         bo.setEmail(rs.getString("email"));
/* 1078 */         bo.setTelephoneForCom(rs.getString("telephoneForCom"));
/* 1079 */         bo.setAddresForCom(rs.getString("addresForCom"));
/* 1080 */         bo.setMobile(rs.getString("mobile"));
/* 1081 */         bo.setIdentificationcard(rs.getString("identificationcard"));
/* 1082 */         bo.setRefreshtime(rs.getDate("refreshtime"));
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/* 1086 */       e.printStackTrace();
/* 1087 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/* 1090 */       dbConClose();
/*      */     }
/* 1092 */     return bo;
/*      */   }
/*      */ 
/*      */   public boolean disableOrEnableUser(String strID, String strType)
/*      */   {
/* 1097 */     boolean flag = true;
/*      */     try
/*      */     {
/* 1100 */       dbConInit();
/* 1101 */       StringBuffer sqlBuffer = new StringBuffer();
/* 1102 */       sqlBuffer.append(" update users set logindisabled = '" + strType + "' ");
/* 1103 */       sqlBuffer.append(" where id= '" + strID + "'");
/* 1104 */       log.info(sqlBuffer.toString());
/* 1105 */       this.dbcon.execUpdate(sqlBuffer.toString());
/*      */     }
/*      */     catch (Exception e) {
/* 1108 */       e.printStackTrace();
/* 1109 */       log.error(e.getMessage());
/* 1110 */       flag = false;
/*      */     }
/*      */     finally {
/* 1113 */       dbConClose();
/*      */     }
/* 1115 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean updateUserRole(String strUserId, String strRoleId)
/*      */   {
/* 1120 */     boolean flag = true;
/*      */     try
/*      */     {
/* 1123 */       dbConInit();
/* 1124 */       String strSQL = " update sysm_user_role set ROLE_ID = '" + strRoleId + "' where USER_ID = '" + strUserId + "' ";
/* 1125 */       log.info(strSQL);
/* 1126 */       this.dbcon.execUpdate(strSQL);
/* 1127 */       strSQL = " update users set rights = '" + strRoleId + "' where id = '" + strUserId + "' ";
/* 1128 */       log.info(strSQL);
/* 1129 */       this.dbcon.execUpdate(strSQL);
/*      */     }
/*      */     catch (Exception e) {
/* 1132 */       e.printStackTrace();
/* 1133 */       log.error(e.getMessage());
/* 1134 */       flag = false;
/*      */     }
/*      */     finally {
/* 1137 */       dbConClose();
/*      */     }
/* 1139 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean deleteUserFromRole(String strUserId, String strRoleId)
/*      */   {
/* 1144 */     boolean flag = true;
/*      */     try
/*      */     {
/* 1147 */       dbConInit();
/* 1148 */       String strSQL = " delete from  sysm_user_role where ROLE_ID = '" + strRoleId + "' and USER_ID = '" + strUserId + "' ";
/* 1149 */       log.info(strSQL);
/* 1150 */       this.dbcon.execUpdate(strSQL);
/* 1151 */       strSQL = " update users set rights = '' where id = '" + strUserId + "' ";
/* 1152 */       log.info(strSQL);
/* 1153 */       this.dbcon.execUpdate(strSQL);
/*      */     }
/*      */     catch (Exception e) {
/* 1156 */       e.printStackTrace();
/* 1157 */       log.error(e.getMessage());
/* 1158 */       flag = false;
/*      */     }
/*      */     finally {
/* 1161 */       dbConClose();
/*      */     }
/* 1163 */     return flag;
/*      */   }
/*      */ 
/*      */   public boolean addUserFromRole(String strUserId, String strRoleId)
/*      */   {
/* 1168 */     boolean flag = true;
/*      */     try
/*      */     {
/* 1171 */       dbConInit();
/* 1172 */       String[] aryUserID = strUserId.split(";");
/* 1173 */       if ((aryUserID != null) && (aryUserID.length > 0))
/*      */       {
/* 1175 */         for (int i = 0; i < aryUserID.length; i++)
/*      */         {
/* 1177 */           String strSQL = " insert into sysm_user_role (ROLE_ID,USER_ID) values ( '" + strRoleId + "' ,'" + aryUserID[i] + "' ) ";
/* 1178 */           log.info(strSQL);
/* 1179 */           this.dbcon.execUpdate(strSQL);
/* 1180 */           strSQL = " update users set rights = '" + strRoleId + "' where id = '" + aryUserID[i] + "' ";
/* 1181 */           log.info(strSQL);
/* 1182 */           this.dbcon.execUpdate(strSQL);
/*      */         }
/*      */       }
/*      */     }
/*      */     catch (Exception e) {
/* 1187 */       e.printStackTrace();
/* 1188 */       log.error(e.getMessage());
/* 1189 */       flag = false;
/*      */     }
/*      */     finally {
/* 1192 */       dbConClose();
/*      */     }
/* 1194 */     return flag;
/*      */   }
/*      */ 
/*      */   public String getRoleByUserID(String strUserID)
/*      */   {
/* 1200 */     String strRoleID = null;
/* 1201 */     ResultSet rs = null;
/*      */     try
/*      */     {
/* 1204 */       dbConInit();
/* 1205 */       String strSQL = " select ROLE_ID from sysm_user_role  where USER_ID = '" + strUserID + "' ";
/* 1206 */       log.info(strSQL);
/* 1207 */       rs = this.dbcon.execQuery(strSQL);
/* 1208 */       if (rs.next())
/* 1209 */         strRoleID = rs.getString("ROLE_ID");
/*      */     }
/*      */     catch (Exception e)
/*      */     {
/* 1213 */       e.printStackTrace();
/* 1214 */       log.error(e.getMessage());
/*      */     }
/*      */     finally {
/* 1217 */       dbConClose();
/*      */     }
/* 1219 */     return strRoleID;
/*      */   }
/*      */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.SystemDAO
 * JD-Core Version:    0.6.2
 */